package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.VehicleFault;
import com.ruoyi.system.service.IVehicleFaultService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * jinggaoController
 * 
 * @author ruoyi
 * @date 2023-09-24
 */
@RestController
@RequestMapping("/jinggao")
public class VehicleFaultController extends BaseController
{
    @Autowired
    private IVehicleFaultService vehicleFaultService;

    /**
     * 查询jinggao列表
     */
    @RequiresPermissions("system:jinggao:list")
    @GetMapping("/list")
    public TableDataInfo list(VehicleFault vehicleFault)
    {
        startPage();
        List<VehicleFault> list = vehicleFaultService.selectVehicleFaultList(vehicleFault);
        return getDataTable(list);
    }

    /**
     * 导出jinggao列表
     */
    @RequiresPermissions("system:jinggao:export")
    @Log(title = "jinggao", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VehicleFault vehicleFault)
    {
        List<VehicleFault> list = vehicleFaultService.selectVehicleFaultList(vehicleFault);
        ExcelUtil<VehicleFault> util = new ExcelUtil<VehicleFault>(VehicleFault.class);
        util.exportExcel(response, list, "jinggao数据");
    }

    /**
     * 获取jinggao详细信息
     */
    @RequiresPermissions("system:jinggao:query")
    @GetMapping(value = "/{vehicleId}")
    public AjaxResult getInfo(@PathVariable("vehicleId") Long vehicleId)
    {
        return success(vehicleFaultService.selectVehicleFaultByVehicleId(vehicleId));
    }

    /**
     * 新增jinggao
     */
    @RequiresPermissions("system:jinggao:add")
    @Log(title = "jinggao", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VehicleFault vehicleFault)
    {
        return toAjax(vehicleFaultService.insertVehicleFault(vehicleFault));
    }

    /**
     * 修改jinggao
     */
    @RequiresPermissions("system:jinggao:edit")
    @Log(title = "jinggao", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VehicleFault vehicleFault)
    {
        return toAjax(vehicleFaultService.updateVehicleFault(vehicleFault));
    }

    /**
     * 删除jinggao
     */
    @RequiresPermissions("system:jinggao:remove")
    @Log(title = "jinggao", businessType = BusinessType.DELETE)
	@DeleteMapping("/{vehicleIds}")
    public AjaxResult remove(@PathVariable Long[] vehicleIds)
    {
        return toAjax(vehicleFaultService.deleteVehicleFaultByVehicleIds(vehicleIds));
    }
}
